#include <bits/stdc++.h>
using namespace std;
#define int long long

int n, k, a[500005];

namespace CR200J {
	int b[1005];
	int dp[1005][1005];
	int dfs(int i, int k) {
		if (dp[i][k] != -1) return dp[i][k];
		if (k == 0) return 0; 
		int ans = 1ll << 60;
		for (int j = i + 1; j <= n; ++j) {
			ans = min(ans, max(dfs(j, k - 1), b[i] + b[j]));
		}
		return dp[i][k] = ans;
	}
	void main() {
		int minid = 1;
		for (int i = 2; i <= n; ++i) {
			if (a[i] < a[minid]) minid = i;
		}
		for (int i = 1; i <= n; ++i) {
			b[(i - minid + n) % n + 1] = a[i];
		}
		memset(dp, 255, sizeof(dp));
		cout << dfs(1, k - 1) << "\n";
	}
}

signed main() {
	freopen("sub.in", "r", stdin); freopen("sub.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	if (n <= 1000) CR200J::main();
	return 0;
}
